Skip to content

Use the original C1 billing source for MCP Todo settlement - #9000

Merged
huangruiteng merged 4 commits into
mainfrom
codex/c1-mcp-receipt-source-20261118
Nov 18, 2026
Merged

huangruiteng merged 4 commits into
mainfrom
codex/c1-mcp-receipt-source-20261118

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Behavior

The default C1 quota guard can admit an MCP Todo with the visible-goal billing source. The shared MCP adapter completes the Todo, then asks for a heartbeat debit. Original-Turn validation rejects the request after the Todo and its successor have already been written. C1 default cutover

The TypeScript plan now requires the existing typed settlement progress on the exact writeback. The CLI adapter forwards that writeback's billing source to the existing one-slot debit command. The quota owner verifies the original Turn, amount, and source. This brings the adapter behavior from the earlier C1 integration fix onto main. C1 integration fix

Validation

  • Ran the deployed Kiro MCP entrypoint against a disposable File-authority Goal over JSON-RPC stdio. The Todo and its successor persisted, and the original-source mismatch denied the debit.
  • Ran the candidate Kiro MCP entrypoint over the same protocol with a fresh Goal and then with the original incomplete Turn. Both settled with visible-goal and exactly one debit. Replaying either completion preserved the Todo and successor and appended no debit.
  • Passed 24 targeted Python tests covering Kiro, Claude, and the shared transport, plus 15 TypeScript host-completion tests. The Claude integration test covers the missing-writeback refusal with the admitted source and verifies a same-Turn replay.
  • Passed the quick premerge canary against main, including the semantic vocabulary and Todo contract checks.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…-mcp-receipt-source-20261118

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…-mcp-receipt-sync-20261118t081815

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · reasoning_effort=max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

通过 Kiro 或 Claude MCP 完成 Todo 的 Agent,需要让这次交付在原工作轮次正确记账。旧执行顺序能完成 Todo 和写回,但随后强制按 heartbeat 扣额。原轮次若属于手动可见的 Goal,扣额会被拒绝,留下业务完成、额度未结算的状态。候选沿用原写回允许的扣额来源。实测 File 和 SQLite 均正确完成并单次扣额,重复完成已关闭的 Todo 可读回同一结算。本次验收覆盖现有 MCP 与 Core 的结算交接。正式安装、平台和模型效果沿 C1 的原交付验收。

改动思路 / Approach

原写回已经记录实际扣额来源,MCP 按这个事实调用现有 quota writer。TypeScript 继续核对回执身份和来源,扣额端重验原账。这次只改 MCP 结算的参数传递和对应回归。写回失败、身份不匹配、未知来源均停在原序列。只有原写回通过并给出已有的扣额来源,才走相同的 debit owner。后继和已完成任务继续由现有事务管理。原写回条件

具体改动 / Changes

评审 head fd0f7cd40aecbcd5fe8bb236ffa08e43efb72f39,base 65ae1d6ec05d0594947a7a47e1e2fc7d7b304e86。3 个文件 +17/-4。按 C1 的 original-billing-source 和 same-turn-idempotent-replay 核对原写回、可执行命令和实际扣额。C1 约定

关键代码讲解

  • writebackContinueWhen 保留原 Goal、Agent、Todo、Turn 和写回状态,要求现有进度协议及受支持的 heartbeat 或 visible-goal。继续条件
  • Python 从通过条件的原写回取值,交给现有 quota spend-slot。基线真实 Kiro 提交在两种 Provider 都完成 Todo,扣额因原来源应为 visible-goal 而被拒绝。候选均扣一次,重复输入返回原身份和幂等回执,后继仍在。两种基线存储随后改用候选时,已经完成的原 Todo 均在原轮次补扣一次,原后继 ID 保持。执行顺序 参数转发
  • 实际 stdio 拒绝其他已注册 Agent 和自带 source 的参数。取得写回前直接请求合法来源也拒绝。验证分别核对输入约束与最终 quota 记录。提前扣额回归

对主干的风险 / Risks

候选的共享 MCP 结算组 8 项和 Kiro 组 12 项通过。相同基线测试 6 项失败、2 项通过。标准本地预检通过6 项直接、13 项选中检查。独立 stdio 在本地 POSIX 上通过 File 和 SQLite 的真实持久化,未覆盖正式安装、Windows 或真实 Kiro 模型执行。

语义与 CI 对齐

计划仍要求原绑定、先写回和后扣额。发起者不能用 MCP 参数替代已提交的扣额证据。Context Off 的守卫保留既有行为,切换调用仍受相同的 Goal 权限保护。

我的整体评价 / Verdict

通过此提交的代码评审。两种存储均按原来源完成扣额,旧 Todo 的重复提交保留同一回执和后继。独立对照还覆盖提前扣额与外来身份的拒绝,安装和平台资格沿父级交付验收。

English verdict: APPROVE. The exact head restores the original debit source and verifies once-only settlement with replay across real File and SQLite Kiro MCP sessions.

…sync-20261118t081815

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · reasoning_effort=max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

通过 Kiro 或 Claude MCP 完成 Todo 的 Agent,需要让这次交付在原工作轮次正确记账。旧执行顺序能完成 Todo 和写回,但随后强制按 heartbeat 扣额。原轮次若属于手动可见的 Goal,扣额会被拒绝,留下业务完成、额度未结算的状态。候选沿用原写回允许的扣额来源。实测 File 和 SQLite 均正确完成并单次扣额,重复完成已关闭的 Todo 可读回同一结算。本次验收覆盖现有 MCP 与 Core 的结算交接。正式安装、平台和模型效果沿 C1 的原交付验收。

改动思路 / Approach

原写回已经记录实际扣额来源,MCP 按这个事实调用现有 quota writer。TypeScript 继续核对回执身份和来源,扣额端重验原账。这次只改 MCP 结算的参数传递和对应回归。写回失败、身份不匹配、未知来源均停在原序列。只有原写回通过并给出已有的扣额来源,才走相同的 debit owner。后继和已完成任务继续由现有事务管理。原写回条件

具体改动 / Changes

评审 head 6da8bd5c4f014baca339fa1184f756d30c9e2ea8,diff base f8ef1a63f12fb042c62b3f5b828a432da1b568b2。3 个文件 +17/-4。与上一版 fd0f7cd4 相比,本次合入了新的 main。Todo、租约和 heartbeat 回执有上游改动,PR 的 3 个文件保持相同。本轮按新基线重新验证整个差异。按 C1 的 original-billing-source 和 same-turn-idempotent-replay 核对原写回、可执行命令和实际扣额。C1 约定

关键代码讲解

  • writebackContinueWhen 保留原 Goal、Agent、Todo、Turn 和写回状态,要求现有进度协议及受支持的 heartbeat 或 visible-goal。继续条件
  • Python 从通过条件的原写回取值,交给现有 quota spend-slot。基线真实 Kiro 提交在两种 Provider 都完成 Todo,扣额因原来源应为 visible-goal 而被拒绝。候选均扣一次,重复输入返回原身份和幂等回执,后继仍在。两种基线存储随后改用候选时,已经完成的原 Todo 均在原轮次补扣一次,原后继 ID 保持。执行顺序 参数转发
  • 实际 stdio 拒绝其他已注册 Agent 和自带 source 的参数。取得写回前直接请求合法来源也拒绝。验证分别核对输入约束与最终 quota 记录。提前扣额回归

对主干的风险 / Risks

候选的 26 项 Python 测试和 15 项 TypeScript Host 结算测试通过。基线的同组 8 项 Python 结算测试中有 6 项失败、2 项通过。标准本地预检通过6 项直接、13 项选中检查。独立 stdio 在本地 POSIX 上通过 File 和 SQLite 的真实持久化,未覆盖正式安装、Windows 或真实 Kiro 模型执行。

语义与 CI 对齐

计划仍要求原绑定、先写回和后扣额。发起者不能用 MCP 参数替代已提交的扣额证据。Context Off 的守卫保留既有行为,切换调用仍受相同的 Goal 权限保护。

我的整体评价 / Verdict

通过此提交的代码评审。两种存储均按原来源完成扣额,旧 Todo 的重复提交保留同一回执和后继。独立对照还覆盖提前扣额与外来身份的拒绝,安装和平台资格沿父级交付验收。

English verdict: APPROVE. The exact head restores the original debit source and verifies once-only settlement with replay across real File and SQLite Kiro MCP sessions.

@huangruiteng
huangruiteng merged commit 7bc56e7 into main Nov 18, 2026
22 of 46 checks passed
@huangruiteng
huangruiteng deleted the codex/c1-mcp-receipt-source-20261118 branch November 18, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants